<?php

namespace app\common\controller;

use Throwable;
use app\common\controller\Backend;
use think\App;
use think\Model;
/**
 * API控制器基类
 */
class Approval
{
    public function  AddApprovalRecord($OldJson, $NewJson, $approval_type,$approval,$AdminId): bool
    {
        $Pdata = [];
        // 入库记录修改
        $Pdata["approval_type"] = $approval_type;
        $Pdata["approval_status"] = 0;
        $Pdata["admin_id"] = $AdminId;
        // 审批拒绝说明
        $Pdata["remark"] = $approval;
        $Pdata["old_json"] = $OldJson;
        $Pdata["new_json"] = $NewJson;
        // 标记已发起审核记录
        return $this->InitiateReview($Pdata);

    }
    // 发起审批
    public function InitiateReview($data):bool
    {
        try {
            $this->model = new \app\admin\model\parts\Approval;
            return $this->model->save($data);
        } catch (Throwable $e) {
            return false;
        }
    }

}